﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Ivory
{
    public abstract class SplashScreenBase : Screenbase {
        //Fields
        public bool IsFinished = false;
        public TimeSpan lifetime, elpased;

        //Construct
        public SplashScreenBase(Game game, float life)
            : base(game)
        {
            IsFinished = false;
            lifetime = TimeSpan.FromSeconds(life);
            elpased = TimeSpan.FromSeconds(0);
        }

        //Methods
        #region #@@ Drawing @@#
        public override void drawScreen(SpriteBatch batch, GameTime time)
        {
            RenderSplash(batch, time); 
        }

        public abstract void RenderSplash(SpriteBatch batch, GameTime time);
        
        #endregion

        #region #@@ Updating @@#
        public override void updateScreen(GameTime time, InputControl input)
        {
            //Update the logic.
            elpased += time.ElapsedGameTime;

            if (elpased <= lifetime)
                UpdateSplash(time);
            else
                IsFinished = true;
        }

        public abstract void UpdateSplash(GameTime time);

        #endregion

        #region #@@ Loading @@#
        public override void loadScreen()
        {
            return; //
        }
        public override void preLoad()
        {
            LoadAssets();
        }

        public abstract void LoadAssets();

        #endregion
    }
}
